#include "main.h"
int main(void)
{
	SystemClockInit();
	GPIO_Init();
	PWM_Init();
	ADC_Init();
	TIMER3_Init();
	TIMER14_Init();
	TIMER16_17_Init();
	DMA_Init();
	DMA_Enable();
	USART_Init();
	SPI_Init();
	LCD_Init();
	LCD_Fill(0,0,240,135,BLACK);
	LCD_DC_PIN_SET();
	DisplayInit();
	xTimeCounter.startCounter = START_UP_DELAY_TIME;
	Systick_Init();
	Systick_Enable();
	NVIC_Init();
	NVIC_ENABLE_DMA_CH1();
	NVIC_ENABLE_TIM3();
	NVIC_ENABLE_TIM14();
	while(xTimeCounter.startCounter)
				;
	MotorInit();
	while(1)
	{
		if( !xTimeCounter.displayCounter ){
			xTimeCounter.displayCounter = DISPLAY_FRESH_TIME;
			DisplayProcess();
		}
	}
}

void DMA1_Channel1_IRQHandler(void)
{
    adcDMAFinishCallBack();
	eMotorStateMachine();
    DMA1->IFCR = 0xFFFFFFFF;
}

void TIM3_IRQHandler(void)
{
	if( TIM3->SR & 0x01 ){

	}

    TIM3->SR = 0;//清除中断标志位
}

void TIM14_IRQHandler(void)
{
	if( TIM14->SR & 0x01 ){

	}

    TIM14->SR = 0;//清除中断标志位
}

void SysTick_Handler(void)
{
	vTimeCounterUpdate();
	MotorAppProcess();
}
